<template>
	<view>
		<input type="text" v-model="imgUrl" placeholder="此处粘贴图片地址"><button type="primary" size="mini"
			@click="download">下载</button>
	</view>
</template>

<script>
	import {
		ref,
		toRefs,
		reactive
	} from 'vue';
	export default {
		setup() {
			const download = () => {
				uni.showLoading({
					title: "下载中..."
				})

				uni.downloadFile({
					url: imgUrl.value,
					success(res) {
						uni.hideLoading();
						console.log(res);
						uni.saveFile({
							tempFilePath: res.tempFilePath,
							success(saveRes) {
								uni.showToast({
									title: "保存成功"
								})
								console.log(saveRes.savedFilePath)
							}
						})
					}
				})
			}

			const imgUrl = ref("")

			return {
				download,
				imgUrl
			}
		}
	}
</script>

<style scoped>

</style>
